<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />    
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>

    <header class="header header-f" style="padding-top:2rem; height:4rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            注册
        </div>
        <div class="header-r aui-pull-right">
            <span>登录</span>
        </div>
    </header>
    <div style="height:4rem;"></div>


    <div class="login">
        <ul>
            <li>
                <input type="number" placeholder="输入手机号" id="phone">
            </li>
            <li>
                <input type="text" placeholder="输入密码" id="password">
            </li>
            <li>
                <input type="number" placeholder="输入验证码" id="code">
                <div class="aui-btn aui-btn-block aui-btn-sm">获取验证码</div>
            </li>
        </ul>

        <div class="aui-btn aui-btn-danger aui-btn-block aui-btn-sm" onclick="register();">注册</div>
    </div>





</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">

    apiready = function(){

    }
    
    // 注册
    function register(){

        var username = $api.byId('phone').value;
        var password = $api.byId('password').value;
        var code = $api.byId('code').value;

        api.ajax({
            url: webAddress + '/a/member/Register/index',
            method: 'post',
            data: {
                values: { 
                 username: username,
                 password: password,
                 code: '1234',
                 imgcode: '1234'
             },
         },
         headers: {
            TOKEN: token,
        },
    },function(ret, err){
        if (ret) {
            api.toast({
                msg: ret.message,
                duration: 2000,
                location: 'bottom'
            });
            $api.setStorage('phone', ret.result.data.tel);
            var jsfun = 'showPhoneNumber();';
            api.execScript({
                name: 'login',
                script: jsfun
            });
            api.closeToWin({
                name: 'login'
            });

        } else {
            api.toast({
                msg: err.body.message,
                duration: 2000,
                location: 'bottom'
            });
            return false;
        }
    });
    }

    function coupondetails(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'coupondetails',
            url: './coupon-details.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    };
    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>